<template>
  <el-container>
    <el-header>
      <el-form :inline="true" :model="form" class="demo-form-inline floatLeft">
        <el-form-item label="合同编号">
          <el-input  placeholder="合同编号" v-model="form.contractNo" ></el-input>
        </el-form-item>
        <el-form-item label="合同名称">
          <el-input  placeholder="合同名称" v-model="form.contractName"></el-input>
        </el-form-item>
        <el-form-item>
            <span class="demonstration">创建时间</span>
            <el-date-picker
              v-model="dates"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至 "
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              :picker-options="pickerOptions">
            </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="searchFn">查询</el-button>
        </el-form-item>
      </el-form>
    </el-header>
    <el-main>
      <el-table
        :data="tableData"
        highlight-current-row
        border
        style="width: 100%"
        height="800">
        <el-table-column label="序号"
                         type="index"
                         width="50"></el-table-column>
        <el-table-column prop="sobId" label="账套ID"></el-table-column>
        <el-table-column prop="sobCode" label="账套缩写"></el-table-column>
        <el-table-column prop="sobName" label="账套名称"></el-table-column>
        <el-table-column prop="proCode" label="省份代码"></el-table-column>
        <el-table-column prop="proName" label="省份名称"></el-table-column>
        <el-table-column prop="leCateCode" label="法律实体类别代码"></el-table-column>
        <el-table-column prop="leCateName" label="法律实体类别"></el-table-column>
        <el-table-column prop="leCode" label="法律实体代码"></el-table-column>
        <el-table-column prop="leName" label="法律实体名称"></el-table-column>
        <el-table-column prop="comCode" label="公司代码"></el-table-column>
        <el-table-column prop="comName" label="公司名称"></el-table-column>
        <el-table-column prop="deptCode" label="部门代码"></el-table-column>
        <el-table-column prop="deptName" label="部门名称"></el-table-column>
        <el-table-column prop="visionFlag" label="版本号"></el-table-column>
        <el-table-column prop="arrairNo" label="合同编码"></el-table-column>
        <el-table-column prop="contractNoLocal" label="合同流水号"></el-table-column>
        <el-table-column prop="contractNoGlobal" label="合同编号"></el-table-column>
        <el-table-column prop="contractName" label="合同名称" width="200"></el-table-column>
        <el-table-column prop="contractDesc" label="合同注释"></el-table-column>
        <el-table-column prop="repositoryNameUnicom" label="我方主体名称" width="150"></el-table-column>
        <el-table-column prop="repositoryNameVendor" label="对方主体名称" width="150"></el-table-column>
<!--        <el-table-column prop="signWay" label="签约方式" width="150"></el-table-column>-->
<!--        <el-table-column prop="yzstaffid" label="运责员工编号" width="150"></el-table-column>-->
<!--        <el-table-column prop="accountmanager" label="客户经理" width="150"></el-table-column>-->
<!--        <el-table-column prop="trelliscode" label="网格编码" width="150"></el-table-column>-->
<!--        <el-table-column prop="trellisname" label="网格名称" width="150"></el-table-column>-->
        <el-table-column prop="contractTypeCode" label="框架合同类型代码"></el-table-column>
        <el-table-column prop="contractTypeName" label="框架合同类型"></el-table-column>
        <el-table-column prop="arrairStatusCode" label="合同业务状态代码"></el-table-column>
        <el-table-column prop="arrairStatusName" label="合同业务状态"></el-table-column>
        <el-table-column prop="contractStatusCode" label="合同状态代码"></el-table-column>
        <el-table-column prop="contractStatusName" label="合同状态"></el-table-column>
        <el-table-column prop="contractCateL1Code" label="合同一级分类代码"></el-table-column>
        <el-table-column prop="contractCateL1Name" label="合同一级分类"></el-table-column>
        <el-table-column prop="contractCateL2Code" label="合同二级分类代码"></el-table-column>
        <el-table-column prop="contractCateL2Name" label="合同二级分类"></el-table-column>
        <el-table-column prop="contractCateL3Code" label="合同三级分类代码"></el-table-column>
        <el-table-column prop="contractCateL3Name" label="合同三级分类" width="150"></el-table-column>
        <el-table-column prop="contractSelectCode" label="对方选择方式代码"></el-table-column>
        <el-table-column prop="contractSelectName" label="对方选择方式"></el-table-column>
        <el-table-column prop="contractDegreeCode" label="合同等级代码"></el-table-column>
        <el-table-column prop="contractDegreeName" label="合同等级"></el-table-column>
        <el-table-column prop="contractPriorityCode" label="优先级代码"></el-table-column>
        <el-table-column prop="contractPriorityName" label="优先级"></el-table-column>
        <el-table-column prop="contractPaymentTypeCode" label="首付款方式代码"></el-table-column>
        <el-table-column prop="contractPaymentTypeName" label="首付款方式"></el-table-column>
        <el-table-column prop="contractApproveLevelCode" label="合同履行级别代码"></el-table-column>
        <el-table-column prop="contractApproveLevelName" label="合同履行级别"></el-table-column>
        <el-table-column prop="contractChangetypeCode" label="合同性质代码"></el-table-column>
        <el-table-column prop="contractChangetypeName" label="合同性质"></el-table-column>
        <el-table-column prop="contractTimelimitCode" label="合同履行期限代码"></el-table-column>
        <el-table-column prop="contractTimelimitName" label="合同履行期限"></el-table-column>
        <el-table-column prop="contractBudgetTypeCode" label="是否预算内代码"></el-table-column>
        <el-table-column prop="contractBudgetTypeName" label="是否预算内"></el-table-column>
        <el-table-column prop="performTypeCode" label="履行类型代码"></el-table-column>
        <el-table-column prop="performTypeName" label="履行类型"></el-table-column>
        <el-table-column prop="performPersonName" label="履行人姓名"></el-table-column>
        <el-table-column prop="performDeptName" label="履行人部门"></el-table-column>
        <el-table-column prop="countersignPersonName" label="会签人名称"></el-table-column>
        <el-table-column prop="isRenew" label="是否续签"></el-table-column>
        <el-table-column prop="accountRate" label="结算比例"></el-table-column>
        <el-table-column prop="takerCode" label="承办人代码"></el-table-column>
        <el-table-column prop="takerName" label="承办人名称"></el-table-column>
        <el-table-column prop="takerMobile" label="承办人联系方式"></el-table-column>
        <el-table-column prop="signName" label="签约代表"></el-table-column>
        <el-table-column prop="currencyCode" label="币种代码"></el-table-column>
        <el-table-column prop="currencyName" label="币种"></el-table-column>
        <el-table-column prop="exchangeRate" label="汇率"></el-table-column>
        <el-table-column prop="financeAmount" label="合同原币总金额"></el-table-column>
        <el-table-column prop="financeRmbmoney" label="人民币金额"></el-table-column>
        <el-table-column prop="financeGbkmoney" label="大写总金额"></el-table-column>
        <el-table-column prop="financeTotal" label="原本位币总金额"></el-table-column>
        <el-table-column prop="projectAmount" label="项目合同金额"></el-table-column>
        <el-table-column prop="payAmount" label="首付款金额"></el-table-column>
        <el-table-column prop="erpInvAmount" label="ERP入库金额"></el-table-column>
        <el-table-column prop="easApplyAmount" label="EAS申请金额"></el-table-column>
        <el-table-column prop="erpPoAmount" label="ERP采购金额"></el-table-column>
        <el-table-column prop="receiveSumAmount" label="收货金额"></el-table-column>
        <el-table-column prop="financeVatRate" label="增值税"></el-table-column>
        <el-table-column prop="financeUnVatAmount" label="不含税总金额"></el-table-column>
        <el-table-column prop="financeRmbUnVatAmount" label="人民币不含增值税总金额"></el-table-column>
        <el-table-column prop="financeVatax" label="增值税额"></el-table-column>
        <el-table-column prop="financeRmbVatax" label="人民币增值税"></el-table-column>
        <el-table-column prop="arrairAmount" label="当前合同总金额"></el-table-column>
        <el-table-column prop="arrairAmountGbk4" label="当前合同大写金额"></el-table-column>
        <el-table-column prop="arrairPayPlan" label="应收/付"></el-table-column>
        <el-table-column prop="arrairPayActual" label="实收/付"></el-table-column>
        <el-table-column prop="arrairBalance" label="余额"></el-table-column>
        <el-table-column prop="auditMoney4" label="审计本位币金额"></el-table-column>
        <el-table-column prop="auditRatio4" label="审计汇率"></el-table-column>
        <el-table-column prop="auditSum4" label="审计金额"></el-table-column>
        <el-table-column prop="auditVatax" label="审计增值税额"></el-table-column>
        <el-table-column prop="auditUnvatAmount" label="审计不含税金额"></el-table-column>
        <el-table-column prop="auditVatRate" label="审计增值税率"></el-table-column>
        <el-table-column prop="fixedAmount" label="是否固定金额"></el-table-column>
        <el-table-column prop="arrairId" label="合同业务ID"></el-table-column>
        <el-table-column prop="arrairIdContract" label="合同业务标识"></el-table-column>
        <el-table-column prop="contractId" label="合同ID"></el-table-column>
        <el-table-column prop="contractIdFinance" label="合同财务信息ID"></el-table-column>
        <el-table-column prop="contractIdArrairNow" label="当前合同ID"></el-table-column>
        <el-table-column prop="contractIdArrairOrigin" label="原始合同ID"></el-table-column>
        <el-table-column prop="provinceid" label="省份ID"></el-table-column>
        <el-table-column prop="companyid" label="公司ID"></el-table-column>
        <el-table-column prop="companyname" label="合同公司名称"></el-table-column>
        <el-table-column prop="draftouttab" label="起草页签块ID"></el-table-column>
        <el-table-column prop="performtab" label="履行页签块ID"></el-table-column>
        <el-table-column prop="lastApproverCode" label="审批人编码"></el-table-column>
        <el-table-column prop="lastApproverName" label="审批人"></el-table-column>
        <el-table-column prop="signStatusCode" label="签约状态代码"></el-table-column>
        <el-table-column prop="signDate" label="签约时间"></el-table-column>
        <el-table-column prop="startDate" label="合同履行开始时间"></el-table-column>
        <el-table-column prop="endDate" label="合同履行结束时间"></el-table-column>
        <el-table-column prop="signDeptName" label="签约部门"></el-table-column>
        <el-table-column prop="approvalDateSend" label="送审日期"></el-table-column>
        <el-table-column prop="approvalDate" label="审批日期"></el-table-column>
        <el-table-column prop="relationid" label="省份ID"></el-table-column>
        <el-table-column prop="relationname" label="关联合同名称"></el-table-column>
        <el-table-column prop="arrairIdOld" label="旧版业务标识"></el-table-column>
        <el-table-column prop="purchaseResultId" label="采购结果编号"></el-table-column>
        <el-table-column prop="creationDate" label="创建时间"></el-table-column>
        <el-table-column prop="createdBy" label="创建人ID"></el-table-column>
        <el-table-column prop="lastUpdateDate" label="更新日期"></el-table-column>
        <el-table-column prop="extnumber2" label="是否三重一大合同"></el-table-column>
        <el-table-column prop="enterperformtime" label="签订盖章信息确认时间"></el-table-column>
        <el-table-column prop="dwaCreationDate" label="DWA创建时间"></el-table-column>
        <!--        <el-table-column-->
        <!--          label="操作"-->
        <!--        >-->
        <!--          <template slot-scope="scope">-->
        <!--            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>-->
        <!--            <el-button type="text" size="small">编辑</el-button>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
      </el-table>
      <el-pagination
        background
        layout="prev, pager, next"
        :total=total class="marginTop"
        :hide-on-single-page="false"
        :page-size="10"
        @current-change="currentChange">
      </el-pagination>
    </el-main>
    <el-footer></el-footer>
  </el-container>
</template>

<script>
  import '@/assets/supply.css'
  import axios from 'axios'
  import {formatDate}from '../utils/formatDate'
  import global from '../utils/global'


  export default {
    name: 'contractDetail',
    methods: {
      handleClick (row) {
        console.log(row)
      },
      searchFn(){
        this.startSize=0
        this.endSize =11
        this.currentPage=1
        this.queryContractList()
        this.queryContractListCount()
      },
      onSubmit () {
        this.queryContractList()
        this.queryContractListCount()
      },
      queryContractList: function () {
        let _this = this
        _this.getQueryParams();
        axios({
          methods: 'get',
          url: global.host+'/contract/queryContractList',
          params: {params: JSON.stringify(_this.queryParams)}
        }).then(res => {
          console.log(res)
          _this.tableData = res.data
        })
      },
      queryContractListCount: function () {
        let _this = this
        _this.getQueryParams();
        axios({
          methods: 'get',
          url: global.host+'/contract/queryContractListCount',
          params: {params: JSON.stringify(_this.queryParams)}
        }).then(res => {
          console.log(res)
          _this.total = res.data
        })
      },
      currentChange(cpage){
        let _this = this;
        _this.currentPage = cpage
        _this.startSize = cpage*10-10
        _this.endSize = cpage*10
        this.onSubmit()
      },
      getQueryParams(){
        let startDate ='';
        let endDate ='';
        if(this.dates.length>0){
          startDate =formatDate(this.dates[0],'yyyy-MM-dd hh:mm')
          endDate =formatDate(this.dates[1],'yyyy-MM-dd hh:mm')
        }
        this.queryParams = {
          startSize:this.startSize,
          endSize:this.endSize,
          startDate :startDate,
          endDate : endDate,
          contractName: this.form.contractName,
          contractNo: this.form.contractNo
        }
      }

    }
  ,
  data()
  {
    return {
      tableData: [],
      total: 0,
      currentPage:1,
      startSize:0,
      endSize:10,
      queryParams :{

      },
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      dates: [],
      form: {
        contractName: '',
        contractNo:''
      }
    };
    }
  }


</script>

<style scoped>

</style>
